<?php

namespace App\Http\Controllers\Article;

use App\Article;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class ArticleController extends Controller {
    //
    public function index() {

        // 添加一条记录
        $article = DB::select('select * from articles where word_id=? limit 1', [1]);
        if (is_null($article)) {
            dd("empty table!");
        }
        d($article);


        $ans = Article::query('word_id', '=', 1)->find(1);
        d($ans);

        $ans = DB::table('articles')->where('word_id', 1)->first();
        dd($ans);


        $newArticle = new Article();
        $newArticle->word_id = 1;
        $newArticle->user_id = 1;
        $newArticle->order = 0;
        $newArticle->content = '一个测试的小帖子';
        $newArticle->good = 0;
        $newArticle->bad = 0;
        $newArticle->tag = 0;
        $newArticle->is_deleted = 0;


        $ans = $newArticle->save();
        dd($ans);


        $ans = Article::all();


        return $ans;
    }


}
